#define DEBUG
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=1000;

int getMax(const int c[maxn+1], const int w[maxn+1], int n) {
	int ret=0;
	for (int i=1, j=1; i<=n; i++) {
		for (; j<=n && c[i]>=w[j]; j++);
		if (j<=n) {
			ret++;
			j++;
		}
	}
	return ret;
}

void del(int v, int *a, int *b, int n) {
	int flag=0;
	for (int i=1; i<=n; i++) {
		if (a[i]!=v) {
			b[i-flag] = a[i];
		} else {
			flag++;
		}
	}
}

int main() {
	freopen("card.in", "r", stdin);
	freopen("card.out", "w", stdout);

	static int c[maxn+1], w[maxn+1], a[maxn+1], b[maxn+1], ans[maxn+1];
	int n;
	scanf("%d", &n);
	for (int i=1; i<=n; i++) {
		scanf("%d", c+i);
		a[i] = c[i];
	}
	for (int i=1; i<=n; i++) {
		scanf("%d", w+i);
	}

	sort(w+1, w+n+1);
	sort(a+1, a+n+1);

	int sum=getMax(a, w, n);
	for (int i=1, now=0; i<=n; i++) {
		del(c[i], a, a, n-i+1);
		int f;
		for (f=1; f<=n-i+1 && w[f]<=c[i]; f++);
		for (int l=f, r=n-i+1, mid; l<=r; ) {
			mid = (l+r)/2;
			del(w[mid], w, b, n-i+1);
			if (now+1+getMax(a, b, n-i)==sum) {
				ans[i] = w[mid];
				l = mid+1;
			} else {
				r = mid-1;
			}
		}
		if (!ans[i]) {
			for (int l=1, r=f-1, mid; l<=r; ) {
				mid = (l+r)/2;
				del(w[mid], w, b, n-i+1);
				if (now+getMax(a, b, n-i)==sum) {
					ans[i] = w[mid];
					l = mid+1;
				} else {
					r = mid-1;
				}
			}
		}
		now += (c[i]<ans[i]);
		del(ans[i], w, w, n-i+1);
	}

	for (int i=1; i<=n; i++) {
		printf("%d ", ans[i]);
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}
